package com.zhongge.cotorller;

import com.zhongge.entity.PageData;
import com.zhongge.entity.Student;
import com.zhongge.service.StudentService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName StudentController
 * @Description TODO
 * @Author zhongge
 * @Version 1.0
 */
@Controller
public class StudentController {
    @Resource
    private StudentService studentService;
    @GetMapping("/page")
    @ResponseBody
    public PageData<Student> pageSel(@RequestParam("page") int pageSize,
                                     @RequestParam("rows") int pageNum){
        return studentService.pageSel(pageSize,pageNum);
    }
    @GetMapping("/index")
    public String index(){
        return "index";
    }

    /**
     * 调度
     * @param name 菜单名字
     * @return 页面
     */
    @GetMapping("/main.do")
    public String dispatch(String name){
        System.out.println(name);
        if (name == null){
            return "fail";
        }else if ("学生管理".equals(name)){
            return "student/info";
        }else if("学生成绩".equals(name)){
            return "student/score";
        }else {
            return "fail";
        }
    }
}
